#include <stdio.h>

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    getchar();

    char arr[n+2][m+2];
    
    // 先初始化为\0
    for (int i = 0;i < n+2;i++)
    {
        for (int j = 0;j < m+2;j++)
        {
            arr[i][j] = 0;
        }
    }
    for (int i = 1;i <= n;i++)
    {
        for (int j = 1;j <= m;j++)
        {
            scanf("%c",&arr[i][j]);
        }
        getchar();
    }

    // 遍历检测i-1 j-1 到 i+1 j+1有多少雷
    for (int i = 1;i <= n;i++)
    {
        for (int j = 1;j <= m;j++)
        {
            if (arr[i][j] == '*')
            {
                printf("*");
                continue;
            }

            int count = 0;
            for (int k = i-1;k <= i+1;k++)
            {
                for (int l = j-1;l <= j+1;l++)
                {
                    if (arr[k][l] == '*')
                    {
                        count++;
                    }
                }
            }

            printf("%d",count);
        }
        printf("\n");
    }
    return 0;
}